First, the SQL that created the stored procedure in MySQL--List all stored procedures show PROCEDURE status;--to view the creation statement for an existing stored procedure, and if this stored procedure does not exist, it will prompt for a SQL error (1305): PROCEDURE Pro_init does not existshow Create PROCEDURE pro_init;--Creating stored Procedure drop PROCEDURE IF EXISTS pro_init; --Delete an existing stored procedure delimiter//--declares that the current MySQL delimiter is//create PROCEDURE
An SQL statement that runs directly into MySQL is normal.
But the result of running this SQL with PHP mysql_query is different, will it be the reason why mysql_query cannot parse?
SQL is as follows:
INSERT into Analysis.caomei_of_list_pvuv (region,isp,uv,pv,date) SELECTTB2.REGION,TB2.ISP,TB2.UV,TB2.PV, ' 2014-05-14 ' as Date from (SELECT tb.region,tb.isp, COUNT (Tb.mac) as Uv,sum (Tb.mac_num) as PV from caomei_ 20140515.caomei_1 as TB WHERE tb.date = ' 2014-05-14 ' GROUP
Jsp adds the date MSSQLSERVER to the database: NSERTintostudent (studentid, time1) values (15, getdate (); MYSQLinsertintotablename (fieldname) values (now ()) obtains the number of ConnectionconnDbConnection rows of a table in the database. connectToDb (); Statementstatcon
Jsp add date MS to database SQL server: NSERT into student (studentid, time1) values ('15', getdate (); my SQL insert into tablename (fieldname) values (now () obtains the Connecti
information:Compared with the self-connected approach, this method requires manual intervention of intermediate results, which is obviously not conducive to automatic processing in the program.Self-connect mode:SELECT b.* from shopping as a,shopping as Bwhere A.name= ' Whitney ' and A.priceGets the following table information:Note the point:Alias A, B although the name is different, but the same table, the purpose of defining aliases is more convenient to delete themselves.The b.* that is obtai
Preface
A database of SQLite is used in the project. The first idea was to find an ORM framework to operate and find the lightweight framework for Ormlite.
Use it, it's very convenient, just record this frame here. Consolidate to Project
General project download jar put into lib on the line.
Jar Download Address: http://ormlite.com/releases/
Maven Project Add this dependency on the line
Because we're working with SQLite, we need to add sqlite jdbc
How to use 1, configure the persistence cl
Mysql_query () cannot parse an SQL statement normally, and it is normal to directly run it in mysql.
However, if mysql_query in php is used to run the SQL statement, the result is different. Is it because mysql_query cannot be parsed?
The SQL statement is as follows:
INSERT INTO analysis.caomei_of_list_pvuv (region,isp,uv,pv,date) SELECTtb2.region,tb2.isp,tb2.uv,tb2.pv,'2014-05-14' AS date FROM (SELECT tb.region,tb.isp, COUNT(tb.mac) AS uv,SUM(tb.mac_num) AS pv FROM caomei
First create the table monthlyorders and import some data according to the following codeCREATE TABLE monthlyorders (ordermonth date,ordernum INT unsigned,primary KEY (ordermonth));INSERT into monthlyorders select ' 2010-02-01 ', 23;insert to monthlyorders select ' 2010-03-01 ', 26;insert into Monthlyorders select ' 2010-04-01 ', 24;insert into monthlyorders select ' 2010-05-01 ', 27;insert into monthlyorders select ' 2010-06-01 ', 26;insert to monthlyorders select ' 2010-07-01 ', 32;insert into
numbers need to be sorted.
1. Create Sequence
First, you must have the create sequence or create any sequence permission,
Create sequence emp_sequence increment by 1 -- add several
Start with 1 -- count from 1
NOMAXVALUE -- do not set the maximum value
NOCYCLE -- always accumulate without repeating
CACHE 10;
Once emp_sequence is defined, you can use CURRVAL, NEXTVAL
CURRVAL = returns the current sequence Value
NEXTVAL = increase the sequence value, and then return the sequence Value
For example
The database inserts, updates, and deletes records in the table.
InsertStatement to insert data
UpdateStatement to update data
DeleteStatement to delete dataReference Table
Insert data without specifying the field name
Insert field name not specifiedCopy codeThe Code is as follows:Mysql> insert into person values (1, 'zhang san', 'mal', 1988 );Query OK, 1 row affected, 1 warning (0.03 sec)Nsert into is followed by the table name and values is followe
A DB Link must be established between one Oracle database and another Oracle database a few days ago to Insert data from one server to another.
Oracle Server A: Sid: SDH, USERID/PW: NM/NM
Oracle Server B: Sid; gsgx, USERID/PW: gs/gs create the following DB Link:
Create a db Link from B to:
Create database link testdb connect to nm identified by nm using 'sdh ';
DB Link is created successfully. Select is correct, but when Insert is executed,
I nsert
return the sequence ValueFor example:Emp_sequence.CURRVALEmp_sequence.NEXTVAL
Where sequence can be used:-SELECT statements that do not contain subqueries, snapshot, and VIEW-The INSERT statement is in the subquery.-In the value of the NSERT statement-UPDATE in SET
See the following example:Insert into emp VALUES(Em1_q. nextval, 'Lewis ', 'cler', 7902, SYSDATE, 1200, NULL, 20 );
SELECT empseq. currval from dual;
Note that:-The first NEXTVAL returns t
The sequence created in oracle is the so-called serial number. It is automatically added each time it is obtained. It is generally used in places where the sequence is sorted by serial number. Www.2cto.com 1. Create Sequence you must have the create sequence or create any sequence permission first, create sequence emp_sequence increment by 1 -- add several start with 1 each time -- count NOMAXVALUE from 1 -- do not set the maximum value NOCYCLE -- accumulate all the time, do not loop CACHE 10; o
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.